package alp.starcode.edms;

import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.EnableScheduling;

import javax.annotation.PostConstruct;
import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 项目启动类
 *
 * @author yanglin
 */
@Slf4j
@EnableScheduling
@SpringBootApplication
public class EdmsApplication {


    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = SpringApplication.run(EdmsApplication.class, args);
        //启动日志输出
        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");
        path = path == null ? "" : path;
        StringBuilder str = new StringBuilder();
        str.append("\n----------------------------------------------------------\n\t");
        str.append("Application service is running! Access URLs:\n\t");
        str.append("Local: \t\thttp://localhost:" + port + path + "/\n\t");
        str.append("External: \thttp://" + ip + ":" + port + path + "/\n\t");
        str.append("Doc: \t\thttp://" + ip + ":" + port + path + "/doc.html\n");
        str.append("----------------------------------------------------------");
        log.info(str.toString());
    }

    @PostConstruct
    public void init() throws Exception {

    }

}
